package com.limi.akka.scheduler;

import akka.actor.AbstractActor;
import akka.actor.Props;
import akka.event.Logging;
import akka.event.LoggingAdapter;


/**
 * @author Limi Pan
 * @create 2018-09-17 11:05
 */
public class WorkerActor extends AbstractActor {

    private LoggingAdapter log = Logging.getLogger(getContext().getSystem(), this);

    public static Props props(){
        return Props.create(WorkerActor.class, () -> new WorkerActor());
    }

    @Override
    public Receive createReceive() {
        return receiveBuilder()
                .matchEquals("scheduler", m -> {
                    log.debug("Receive the message:{}, receive time:{}", m, SchedulerTest.getNowTime());
                })
                .matchEquals("hello", m -> {
                    System.out.println("receive the message:" + m + ", time:" + SchedulerTest.getNowTime());
                })
                .matchEquals("tick", m -> {
                    System.out.println("receive the message 'tick', time:" + SchedulerTest.getNowTime());
                })
                .build();
    }

}
